
#import "ViewController.h"

@implementation ViewController

- (id)init 
{
    if (self = [super init]) {
        CGRect rect = [[UIScreen mainScreen] bounds];
		glView = [[EAGLView alloc] initWithFrame:rect];

        UIScreen* mainscr = [UIScreen mainScreen];
        float w = mainscr.currentMode.size.width;

        // Change to the next lines if we make resources for different resolutions
        [glView setup:2 inputScale:w==640 ? 2 : 1];

//        [glView setup:w==640 ? 2 : 1];
    }
    return self;
}

- (void)loadView 
{
	self.view = glView;
}

- (void)viewDidLoad 
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
	NSLog(@"ViewController:viewWillAppear");
	[glView startAnimation];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
	NSLog(@"ViewController:viewWillDisappear");
	[glView stopAnimation];
}

- (void)didReceiveMemoryWarning 
{
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	NSLog(@"ViewController:didReceiveMemoryWarning");
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload 
{
    [super viewDidUnload];
	NSLog(@"ViewController:viewDidUnload");
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (void)dealloc 
{
    [super dealloc];
}
@end
